const express = require('express')
const boom = require('boom')
const { wait_scan, login, send_image } = require('./api')
const { config } = require('./api/trophy')
// 注册路由
const router = express.Router()




router.get('/', (req, res, next) => {
  console.log(req.body);
  res.send("111")
})




router.post('/alt', function (req, res, next) {
  let { qrid } = req.body
  setTimeout(async () => {
    let { alt, msg } = await wait_scan(qrid)
    let { sub, sub_msg } = await login(alt)
    let fpx_msg = await config(sub)
    let json = {
      msg,
      sub_msg,
      fpx_msg
    }
    res.send(json)
  }, 1000)
})


router.get('/img', function (req, res, next) {
  setTimeout(async() => {
    let data = await send_image()
    res.send(data)
  },1000)
})














//SUB
router.post('/SUB', function (req, res, next) {
  console.log(req.body);
  res.send("1111")
})

router.use((req, res, next) => {
  next(boom.notFound('接口不存在'))
})















module.exports = router